<%@ page language="java" contentType="text/html; charset=UTF-8"
		 pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path;
%>
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
	<title>${config.appName}新生报名</title>
	<link rel="stylesheet" href="<%=basePath %>/style/weui.css"/>
    <link rel="stylesheet" href="<%=basePath %>/style/weui2.css"/>
    <link rel="stylesheet" href="<%=basePath %>/style/weui3.css"/>
	<script src="<%=basePath %>/js/zepto.min.js"></script>
	<script src="<%=basePath %>/js/picker-city.js"></script>
	<script src="<%=basePath %>/js/picker.js"></script>
	<script src="<%=basePath %>/js/select.js"></script>
<body ontouchstart>
  <div id="mainBox">
	<form name="formBaomingForm" id="formBaomingForm" action="submit" method="post">
		<div class="weui_cells weui_cells_form" style="margin-top:-8px;" id="sj">
			<img style="width:100%;" src="<%=basePath %>/images/xinshengbaoming@3x.png">
			<input type="hidden" name="signUpType" value="${signUpType }"/>
			<input type="hidden" name="id"/>
			<div class="weui_cell f-red bd-t0" style="padding: 10px;">说明：所有项目必填，如无相关资料，请填写“无”。</div>
			<div class="weui_cell lblue">
				<div class="weui_cell_bd weui_cell_primary">
					<p class="f-blue bold">学生基本资料</p>
				</div>
			</div>
			<div class="weui_cell" style="padding-top:15px;">
				<div class="weui_cell_hd"><label class="weui_label">学生姓名</label></div>
				<div class="weui_cell_bd weui_cell_primary">
					<input class="weui_input" type="text" name="studentName" placeholder="请输入学生姓名">
				</div>
			</div>

			<div class="weui_cell">
				<div class="weui_cell_hd"><label class="weui_label">学生性别</label></div>
				<div class="weui_cell_bd weui_cell_primary">
					<input class="weui_input" type="text" name="studentSex" id="studentSex" placeholder="请选择">
				</div>
			</div>

			<div class="weui_cell">
				<div class="weui_cell_hd"><label class="weui_label">民族</label></div>
				<div class="weui_cell_bd weui_cell_primary">
					<input class="weui_input" type="text" name="nation" id="nation" placeholder="请输入民族">
				</div>
			</div>

			<div class="weui_cell">
				<div class="weui_cell_hd"><label class="weui_label">出生日期</label></div>
				<div class="weui_cell_bd weui_cell_primary">
					<input class="weui_input" id="studentBirthday" name="studentBirthday" type="date" value="">
				</div>
			</div>

			<div class="weui_cell">
				<div class="weui_cell_hd"><label class="weui_label">身体状况</label></div>
				<div class="weui_cell_bd weui_cell_primary">
					<input class="weui_input" type="text" name="healthy" id="healthy" placeholder="请选择">
				</div>
			</div>

			<div class="weui_cell">
				<div class="weui_cell_hd"><label class="weui_label">原就读幼儿园</label></div>
				<div class="weui_cell_bd weui_cell_primary">
					<input class="weui_input" type="text" id="baseSchool" name="baseSchool" placeholder="需注明省市区">
				</div>
			</div>


			<div class="weui_cell">
				<div class="weui_cell_hd"><label class="weui_label">身份证号码</label></div>
				<div class="weui_cell_bd weui_cell_primary">
					<input class="weui_input" type="text" id="studentIdNo" name="studentIdNo" placeholder="请输入学生的证件号" />
				</div>
			</div>
			<div class="weui_cell">
			    <div class="weui_cell_hd"><label for="" class="weui_label">报读年级</label></div>
			    <div class="weui_cell_bd weui_cell_primary">
	                <input class="weui_input" type="text" name="signGrade" id="signGrade" placeholder="请选择">
	            </div>
		    </div>
			<div class="weui_cell">
				<div class="weui_cell_hd"><label class="weui_label">籍贯</label></div>
				<div class="weui_cell_bd weui_cell_primary">
					<input class="weui_input" type="text" id="nativePlace" name="nativePlace" placeholder="例：广东佛山">
				</div>
			</div>


			<div class="weui_cell">
				<div class="weui_cell_hd"><label class="weui_label">户籍所在地</label></div>
				<div class="weui_cell_bd weui_cell_primary">
					<input class="weui_input" type="text" id="houseSSQ" name="houseSSQ" placeholder="请输入户籍详细地址">
				</div>
			</div>

			<div class="weui_cell">
				<div class="weui_cell_hd"><label class="weui_label">户口所在镇街</label></div>
				<div class="weui_cell_bd weui_cell_primary">
					<input class="weui_input" type="text" id="houseAddr" name="houseAddr" placeholder="请输入户口所在镇街">
				</div>
			</div>

			<div class="weui_cell">
				<div class="weui_cell_hd"><label class="weui_label">家庭住址</label></div>
				<div class="weui_cell_bd weui_cell_primary">
					<input class="weui_input" type="text" id="familyAddr" name="familyAddr" placeholder="请输入家庭详细住址">
				</div>
			</div>

			<div class="weui_cell lblue">
				<div class="weui_cell_bd weui_cell_primary">
					<p class="f-blue bold">家庭主要成员资料</p>
				</div>
			</div>
			<div class="weui_cell">
				<div class="weui_cell_hd"><label class="weui_label">父亲是否监护人</label></div>
				<div class="weui_cell_bd weui_cell_primary">
					<input class="weui_input" type="text" id="fatherIsGuardian" name="fatherIsGuardian" placeholder="请选择">
				</div>
			</div>
			<div class="weui_cell">
				<div class="weui_cell_hd"><label class="weui_label">父亲姓名</label></div>
				<div class="weui_cell_bd weui_cell_primary">
					<input class="weui_input" type="text" name="fatherName" placeholder="请输入父亲姓名">
				</div>
			</div>
			<div class="weui_cell">
				<div class="weui_cell_hd"><label class="weui_label">父亲电话</label></div>
				<div class="weui_cell_bd weui_cell_primary">
					<input class="weui_input" type="number" pattern="[0-9]*" name="fatherPhone" placeholder="请输入父亲电话">
				</div>
			</div>
			<div class="weui_cell">
				<div class="weui_cell_hd"><label class="weui_label">父亲单位</label></div>
				<div class="weui_cell_bd weui_cell_primary">
					<input class="weui_input" type="text" name="fatherCompany" placeholder="请输入父亲单位">
				</div>
			</div>
			<div class="weui_cell">
				<div class="weui_cell_hd"><label class="weui_label">母亲是否监护人</label></div>
				<div class="weui_cell_bd weui_cell_primary">
					<input class="weui_input" type="text" id="motherIsGuardian" name="motherIsGuardian" placeholder="请选择">
				</div>
			</div>
			<div class="weui_cell">
				<div class="weui_cell_hd"><label class="weui_label">母亲姓名</label></div>
				<div class="weui_cell_bd weui_cell_primary">
					<input class="weui_input" type="text" name="motherName" placeholder="请输入母亲姓名">
				</div>
			</div>
			<div class="weui_cell">
				<div class="weui_cell_hd"><label class="weui_label">母亲电话</label></div>
				<div class="weui_cell_bd weui_cell_primary">
					<input class="weui_input" type="number" pattern="[0-9]*" name="motherPhone" placeholder="请输入母亲电话">
				</div>
			</div>
			<div class="weui_cell">
				<div class="weui_cell_hd"><label class="weui_label">母亲单位</label></div>
				<div class="weui_cell_bd weui_cell_primary">
					<input class="weui_input" type="text" name="motherCompany" placeholder="请输入母亲单位">
				</div>
			</div>
			<div class="weui_cell lblue">
				<div class="weui_cell_bd weui_cell_primary">
					<p class="f-blue bold">就读方式</p>
				</div>
			</div>
			<div class="weui_cell">
				<div class="weui_cell_hd"><label class="weui_label">就读方式</label></div>
				<div class="weui_cell_bd weui_cell_primary">
					<input class="weui_input" type="text" id="schoolStudyType" name="schoolStudyType" placeholder="请选择就读方式">
				</div>
			</div>
			<p style="padding: 0px 15px;color: #d97e2e;font-size: 0.9rem;">学校开放日时间：2019年12月21日上午9:00，学校将举行校园开放日活动（面向转学生及家长），欢迎家长和孩子莅临参加。</p>
			<div class="weui_btn_area">
				<a id="formSubmitBtn" href="javascript:formBaomingTj()" class="weui_btn weui_btn_primary">提交报名</a>
			</div>
		</div>
	</form>
	<div class="weui_tabbar hide" style="padding: 5px;">
		<div class="weui_cells_tips">
			<span style="color:red" id="result"></span>请再次核查信息，如果有误请点击【<a href="javascript:baomingUpdate()">修改</a>】
		</div>
	</div>
  </div>
</body>
<script>
    $(function() {
    	if(!/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
     		$("#mainBox").attr("style","width:450px;margin: 0 auto;")
     	}
    	initGrade();
        $("#studentBirthday").datetimePicker({title:"选择日期",m:1});
        $("#houseSSQ").cityPicker({
            title: "户籍所在地"
        });
        $("#schoolStudyType").select({
            title: "选择就读方式",
            items: [
                {
                    title: "走读 (17:30放学)",
                    value: "1",
                },
                {
                    title: "晚修后走读 (一年级20：00放学，二、三、四、五年级 20:30放学)",
                    value: "2",
                },
                {
                    title: "住宿 (周日19:00上学、周五16:10放学)",
                    value: "3",
                }
            ]
        });
        $("#nation").picker({
            title: "请选择民族",
            autoClose:true,
            cols: [{textAlign: 'center',
                values: [
                    "汉族", "蒙古族",  "回族", "藏族", "维吾尔族", "苗族",  "彝族", "壮族", "布依族", "朝鲜族",
                    "满族", "侗族", "瑶族", "白族", "土家族", "哈尼族", "哈萨克族", "傣族", "黎族", "傈僳族",
                    "佤族", "畲族", "高山族", "拉祜族", "水族", "东乡族", "纳西族", "景颇族", "柯尔克孜族",
                    "土族", "达斡尔族", "仫佬族", "羌族", "布朗族", "撒拉族", "毛南族", "仡佬族", "锡伯族",
                    "阿昌族", "普米族", "塔吉克族", "怒族", "乌孜别克族", "俄罗斯族", "鄂温克族", "德昂族",
                    "保安族", "裕固族", "京族", "塔塔尔族", "独龙族", "鄂伦春族", "赫哲族", "门巴族", "珞巴族",
                    "基诺族", "亻革家人", "穿青人"
                ]
            }]
        });
        $("#studentSex").picker({
            title: "请选择学生性别",
            autoClose:true,
            cols: [{textAlign: 'center',
                values: ['男孩','女孩']
            }]
        });
        $("#fatherIsGuardian").picker({
            title: "请选择",
            autoClose:true,
            cols: [{textAlign: 'center',
                values: ['是','否']
            }]
        });
        $("#motherIsGuardian").picker({
            title: "请选择",
            autoClose:true,
            cols: [{textAlign: 'center',
                values: ['是','否']
            }]
        });
    })
    function initGrade() {
		var d = new Date();
		var grade = d.getFullYear()+((d.getMonth()+1)<9 ? 0 : 1)+"年秋季一年级新生";
		$("#signGrade").picker({
	        title: "请选择",
	        autoClose:true,
	        cols: [{textAlign: 'center',
	                values: [grade]
	              }]
	    });
	}
    function formBaomingTj(){
        if(formBaomingForm.studentName.value.trim()==""){
            $.alert("请输入学生姓名","");
            return false;
        }
        if(formBaomingForm.studentSex.value.trim()==""){
            $.alert('请选择学生性别',"");
            return false;
        }
        if(formBaomingForm.studentBirthday.value.trim()==""){
            $.alert('请输入生日',"");
            return false;
        }
        var sfxh=formBaomingForm.studentIdNo.value.trim();
        if(sfxh==""){
            $.alert('请输入证件号',"");
            return false;
        }
        var fatherIsGuardian=formBaomingForm.fatherIsGuardian.value.trim();
        var motherIsGuardian=formBaomingForm.motherIsGuardian.value.trim();
        if(fatherIsGuardian==""){
            $.alert('请选择父亲是否监护人',"");
            return false;
        }
        if(motherIsGuardian==""){
            $.alert('请选择母亲是否监护人',"");
            return false;
        }
        var fqdh=formBaomingForm.fatherPhone.value.trim();
        var mqdh=formBaomingForm.motherPhone.value.trim();
        if(fqdh=="" && mqdh==""){
            $.alert('父亲电话和母亲电话必须填写一个',"");
            return false;
        }
        if(formBaomingForm.schoolStudyType.value.trim()==""){
            $.alert('请选择就读方式',"");
            return false;
        }
        var data = $("#formBaomingForm").serialize();
        var schoolStudyType = $("#schoolStudyType").attr("data-values");
        data = replaceParamVal(data,"schoolStudyType",schoolStudyType);
        $.ajax({
            url: "<%=basePath %>/signup/student/addNewborn",
            type: 'POST',
            dataType : "json",
            data: data,
            success: function(data) {
                if (data.code == "000") {
                    $.toast("报名提交成功");
                    $("#result").html("报名提交成功");
                    $("input[name='id']").val(data.data);
                    $(".weui_cells_form").find(".weui_cell .weui_cell_primary")
                        .each(function(i,v) {
                            $(v).children().attr("disabled",true);
                        });
                    $(".weui_tabbar").show();
                } else {
                    $.toptips(data.msg);
                }
            },
            error: function(data) {
                $.toptips("提交异常,请联系管理员");
            }
        });
    }
    function baomingUpdate() {
        $(".weui_cells_form").find(".weui_cell .weui_cell_primary")
            .each(function(i,v) {
                $(v).children().removeAttr("disabled");
            });
        $(".weui_tabbar").hide();
    }
    function replaceParamVal(oUrl,paramName,replaceWith) {
        var re=eval('/('+ paramName+'=)([^&]*)/gi');
        var nUrl = oUrl.replace(re,paramName+'='+replaceWith);
        return nUrl;
    }
</script>
</html>